package com.banach.prema.im.callback;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * 回调应答
 * @author ajun
 *
 */
public class CallBackResponse {
	private String actionStatus;
	private String errorInfo = "";
	private Integer errorCode = 0;
	private JSONArray msgBody;
	
	public static CallBackResponse createRejectResponse(String errorInfo) {
		CallBackResponse response = new CallBackResponse();
		response.setActionStatus("OK");
		response.setErrorCode(1);
		response.setMsgBody(new JSONArray());
		return response;
	}
	
	public static CallBackResponse createSuccessResponse() {
		CallBackResponse response = new CallBackResponse();
		response.setActionStatus("OK");
		return response;
	}
	
	public static CallBackResponse createFallResponse(String errorInfo) {
		CallBackResponse response = new CallBackResponse();
		response.setActionStatus("FALL");
		response.setErrorInfo(errorInfo);
		return response;
	}
	public String getActionStatus() {
		return actionStatus;
	}
	public void setActionStatus(String actionStatus) {
		this.actionStatus = actionStatus;
	}
	public String getErrorInfo() {
		return errorInfo;
	}
	public void setErrorInfo(String errorInfo) {
		this.errorInfo = errorInfo;
	}

	public Integer getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(Integer errorCode) {
		this.errorCode = errorCode;
	}

	public JSONArray getMsgBody() {
		return msgBody;
	}

	public void setMsgBody(JSONArray msgBody) {
		this.msgBody = msgBody;
	}

	public JSONObject toJson() {
		JSONObject map = new JSONObject();
		map.put("ActionStatus", actionStatus);
		map.put("ErrorInfo", errorInfo);
		map.put("ErrorCode", errorCode);
		map.put("ActionStatus", actionStatus);
		if(msgBody!=null){
			map.put("MsgBody", msgBody);
		}
		return map;
	}
}
